var a = getApp(), t = require("../../../mybehaviors/location/location");

Page({
    behaviors: [ t ],
    data: {
        isvalue: 1,
        cityName: "",
        page: 1,
        current_page: 1,
        last_page: 1
    },
    onLoad: function(a) {
        var t = this;
        if (this.setData({
            id: a.id
        }), a.addressData) {
            var e = JSON.parse(a.addressData);
            this.setData({
                "point.lat": e.latitude,
                "point.lng": e.longitude,
                address: e.title,
                title: e.title,
                city: e.city
            }), this.getdata();
        } else this._getLocation(function() {
            t.getdata();
        });
    },
    tapShow: function(a) {
        console.log(a);
        var t = this.data.isInfo.hold_id, e = a.currentTarget.dataset.item.store_id;
        wx.navigateTo({
            url: "/packageH/o2o/storeConsumeShow/storeConsumeShow?id=" + t + "&store_id=" + e
        });
    },
    tapLoaction: function() {
        wx.navigateTo({
            url: "/packageC/o2o/o2oLocation/o2oLocation?tag=storeConsume&id=" + this.data.id
        });
    },
    searchTxt: function(a) {
        console.log(a), this.setData({
            store_name: a.detail.value
        });
    },
    goSearch: function(a) {
        this.setData({
            page: 1
        }), this.getdata();
    },
    blurgoSearch: function(t) {
        a._isTextEmpty(this.data.store_name) || (this.setData({
            page: 1
        }), this.getdata());
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) console.log("没有更多"); else {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    getdata: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.store-card.Frontend.Modules.Card.Controllers.detail.index"), o = a.qqMapTransBMap(parseFloat(t.data.point.lng), parseFloat(t.data.point.lat));
        a._postNetWork({
            url: e,
            data: {
                card_id: t.data.id,
                lat: o.lat,
                lng: o.lng,
                store_name: t.data.store_name,
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(a) {}
                }), 1 == e.result ? (console.log(e), t.setData({
                    isInfo: e.data,
                    page_list: e.data.page_list.data,
                    current_page: e.data.page_list.current_page,
                    last_page: e.data.page_list.last_page
                })) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    getMoreData: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.store-card.Frontend.Modules.Card.Controllers.detail.index"), o = a.qqMapTransBMap(parseFloat(t.data.point.lng), parseFloat(t.data.point.lat));
        a._postNetWork({
            url: e,
            data: {
                card_id: t.data.id,
                lat: o.lat,
                lng: o.lng,
                store_name: t.data.store_name,
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                if (wx.hideLoading({
                    success: function(a) {}
                }), 1 == e.result) {
                    var o = e.data.page_list.data;
                    t.setData({
                        page_list: Object.assign(t.data.page_list, o),
                        current_page: e.data.page_list.current_page,
                        last_page: e.data.page_list.last_page
                    });
                } else wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    }
});